<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class IndexAction extends BaseAccountAction {

	public function _empty() {
		$this->error("参数错误");
	}

	//显示资料
	public function index() {
		if (empty($this->uid)) {
			$this->display("Login_index");
			exit();
		}
		$this->init();
		$_subscibe = D("Subscibe")->cache("subscibe")->select();
		if ($this->profile["email_notice_config"])
			$emailNoticeConfig = explode(",", $this->profile["email_notice_config"]);
		if ($this->profile["mobile_notice_config"])
			$mobileNoticeConfig = explode(",", $this->profile["mobile_notice_config"]);

		foreach ($_subscibe as $key => $val) {
			$subscibe[$_subscibe[$key]["subscibe_id"]] = $_subscibe[$key];
		}
		//合并属性
		foreach ($emailNoticeConfig as $key => $val) {
			$subscibe[$val]["email"] = true;
		}
		foreach ($mobileNoticeConfig as $key => $val) {
			$subscibe[$val]["mobile"] = true;
		}
		$this->assign('subscibe', $subscibe);
		$this->display();
	}

	//保存邮件提醒配置
	public function saveEmailNoticeConfig() {
		$User = D('User');
		//获取设置项信息
		$num = implode($_POST['email'], ',');
		//保存设置项信息
		$result = $User->where("user_id=" . $this->uid)->setField('email_notice_config', $num);
		$this->ajaxReturn(null, '保存成功!', 1);
	}

	//保存手机提醒配置
	public function saveMobileNoticeConfig() {
		$User = D('User');
		//获取设置项信息
		$num = implode($_POST['sms'], ',');
		//保存设置项信息
		$result = $User->where("user_id=" . $this->uid)->setField('mobile_notice_config', $num);
		$this->ajaxReturn(null, '保存成功!', 1);
	}

}

?>
